package za.org.jcicada.katcp;

/**
 * SensorValueBase.java
 *
 * @author Simon Cross
 *
 * Created on October 27, 2008, 18:03
 */

import za.org.jcicada.katcp.ISensorValue;

import java.util.Date;

/**
 * A base class for KAT device sensor values.
 */
public class SensorValueBase implements ISensorValue {

    /**
     * Time when the sensor value was recored in milliseconds since the Unix epoch.
     */
    protected long timestamp;

    /**
     * The status of the sensor when the value was recorded.
     */
    protected ISensorValue.Status status;

    /**
     * Construct sensor value with current timestamp and status set to unknown.
     */
    public SensorValueBase() {
        timestamp = new Date().getTime();
        status = ISensorValue.Status.UNKNOWN;
    }

    /**
     * Construct sensor with specified timestamp and status.
     *
     * @param timestamp  Time when the sensor value was recored in milliseconds since the Unix epoch.
     * @param status  The status of the sensor when the value was recorded.
     */
    public SensorValueBase(long timestamp, ISensorValue.Status status) {
        this.timestamp = timestamp;
        this.status = status;
    }

    /**
     * Return the value's timestamp in milliseconds.
     */
    public long getTimestamp() {
        return timestamp;
    }

    /**
     * Return the sensor status.
     */
    public ISensorValue.Status getStatus() {
        return status;
    }
}
